<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'新建日历事项'))}
	<div class="frame">
		<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"  >
			<input type="hidden" id="ajax" name="ajax" value="0">
			<input type="hidden" id="opmode" name="opmode" value="add">
			<input type="hidden" name="actor" id="actor">
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="name">标题*：</label>
						
							<input class="input" type="text" id="name" name="name" check="required" info="请输入标题">
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="name">开始时间*：</label>
						
							<input type="text" id="start_time" name="start_time" readonly="readonly" class="input input-date-time" check="required" info="请输入开始日期">
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" for="name">结束时间*：</label>
						
							<input type="text" id="end_time" name="end_time" readonly="readonly"
							class="input input-date-time" check="required" info="请输入结束日期" readonly="readonly">
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="location">地点：</label>
						
							<input class="input" type="text" id="location" name="location">
						</div>
					</div>
				</div>
				<div class="box col-12">
					
						<label class="input-label" for="location">类型：</label>
						
							<select check="required" info="请选择类型" class="input" name='type' id='type'>
								<option value=''>请选择类型</option>
								<php>
									if($auth->admin){
									echo "<option value='1'>公司日程</option>";
									echo" <option value='2'>部门日程</option>";
									echo "<option value='3'>个人日程</option>";
									}else if($auth->write){
									echo "<option value='2'>部门日程</option>";
									echo "<option value='3'>个人日程</option>";
									}else if($auth->read){
									echo "<option value='3'>个人日程</option>";
									};
								</php>
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="frame">
				<div class="box col-12">
					
						<label class="input-label" for="location">参与人员：</label>
						
							<div id="actor_wrap" class="input-box">
								<a class="add-on" id="btn_select_actor"><i class="fa fa-user"></i> </a>
								<div class="wrap" >
									<span class="address_list"></span>
									<span class="text" >
										<input class="letter" type="text"  >
									</span>
								</div>
								<div class="search dropdown ">
									<ul class="dropdown-menu"></ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			
				<div class="col-sm-12">
					<textarea  class="editor" id="content" name="content" style="width:100%;height:300px;"></textarea>
				</div>
			</div>
			
				<label class="input-label" >附件：</label>
				
					{:widget('file_upload/add')}
				</div>
			</div>
			
				<div class="col-sm-offset-2 input-block">
					<a class="btn btn-normal" onclick="save()">保存</a>
					<a  class="btn btn-return" onclick="go_return_url();">取消</a>
				</div>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global','uploader','editor'], function() {
			var $ = layui.jquery;
			
			$('#btn_save').on('click', function() {
				$("#actor").val("");
				$("#actor_wrap span.address_list span").each(function() {
					$("#actor").val($("#actor").val() + $(this).find("b").text() + '|' + $(this).attr("data") + ";");
				});
				send_form("form_data", "{:url('add_save')}", "{:url('index')}", function(ret) {
					if (ret.status) {
						layer.msg(ret.info);
						location.reload(true);
					} else {
						layer.msg(ret.info);
						return false;
					}
				});
			});

			$("#btn_add").on('click', function() {
				winopen("{:url('add')}", 560, 470);
			});

			$('#btn_select_actor').on('click', function() {
				winopen("{:url('popup/actor')}", 560, 470);
			});
		});

	</script>
</block>